{js:artTemplate}
<script type='text/javascript' src='{theme:javascript/artTemplate/area_select.js}'></script>

{set:$ship=$this->data}
<div class="headbar clearfix">
	<div class="position">订单<span>></span><span>快递单管理</span><span>></span><span>{if:isset($ship['id'])}修改{else:}添加{/if}发货信息</span></div>
</div>

<form name="ModelForm" action="{url:/order/ship_info_update}" method="post">
<div class="content_box">
	<div class="content form_content">
		<table id="tab-1" class="form_table" name="table">
			<col width="150px" />
			<col />
			<tr>
				<th>发货点名称：</th><input type="hidden" name="sid" value="{$ship['id']}"/>
				<td><input class="normal" name="ship_name" type="text" pattern="required" value="{$ship['ship_name']}" alt="发货点名称"//><label>*发货地点名称</label></td>
			</tr>
			<tr>
				<th>发货人姓名：</th>
				<td><input class="normal" name="ship_user_name" type="text" pattern="required" value="{$ship['ship_user_name']}"  alt="发货人姓名"/><label>*发货人名称</label></td>
			</tr>
			<tr>
				<th>性别：</th>
				<td><label class='attr'><input type="radio" name="sex" value="1" checked/>先生</label><label class='attr'><input type="radio" name="sex" value="0" {if:$ship['sex']==0}checked='checked'{/if}/>女士</label><label>*</label></td>
			</tr>
			<tr>
				<th>地区：</th>
				<td>
					<select name="province" child="city,area" onchange="areaChangeCallback(this);"></select>
					<select name="city" child="area" parent="province" onchange="areaChangeCallback(this);"></select>
					<select name="area" parent="city" pattern="required"></select>
				</td>
			</tr>
			<tr>
				<th>地址：</th>
				<td><input class="normal" name="address" type="text" pattern="required" value="{$ship['address']}"  alt="具体地址错误"/><label>*具体地址</label></td>
			</tr>
			<tr>
				<th>邮编：</th>
				<td><input class="normal" name="postcode" type="text" pattern="zip" value="{$ship['postcode']}" empty alt="邮编错误"/><label>邮政编码</label></td>
			</tr>
			<tr>
				<th>手机：</th>
				<td><input class="normal" name="mobile" type="text" pattern='mobi' value="{$ship['mobile']}"/><label>*手机号码</label></td>
			</tr>
			<tr>
				<th>电话：</th>
				<td><input class="normal" name="telphone" type="text" pattern="phone" empty alt="电话号码错误" value="{$ship['telphone']}" /></td>
			</tr>
			<tr>
				<th></th>
				<td><label><input type="checkbox" name="is_default" value="1" {if:$ship['is_default']==1}checked='checked'{/if}/>&nbsp;设置为默认地址</label></td>
			</tr>
		</table>
		<table class="form_table">
			<col width="150px" />
			<col />
			<tr>
				<td></td>
				<td><button class="submit" type="submit"><span>保 存</span></button></td>
			</tr>
		</table>
	</div>
</div>
</form>

<script type='text/javascript'>
//DOM加载完毕
$(function(){
	//初始化地域联动
	template.compile("areaTemplate",areaTemplate);

	{if:isset($ship) && $ship}
	createAreaSelect('province',0,{$ship['province']});
	createAreaSelect('city',{$ship['province']},{$ship['city']});
	createAreaSelect('area',{$ship['city']},{$ship['area']});
	{else:}
	createAreaSelect('province',0,'');
	{/if}
});

/**
 * 生成地域js联动下拉框
 * @param name
 * @param parent_id
 * @param select_id
 */
function createAreaSelect(name,parent_id,select_id)
{
	//生成地区
	$.getJSON("{url:/block/area_child}",{"aid":parent_id,"random":Math.random()},function(json)
	{
		$('[name="'+name+'"]').html(template.render('areaTemplate',{"select_id":select_id,"data":json}));
	});
}
</script>